﻿<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="UpdatePageTemplateJS" Rights="EditListItems,AddAndCustomizePages"
                 ScriptSrc="spfpub/modals/RibbonActionCommands.js"
                 Location="ScriptLink"
                 Sequence="100">
  </CustomAction>
  <CustomAction Id="UpdatePageTemplateOnPage" Location="CommandUI.Ribbon" Rights="EditListItems,AddAndCustomizePages" >
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.WebPartPage.Actions.Controls._children">
          <Button Id="Ribbon.WebPartPage.Actions.Controls.UpdatePageTemplateOnPage"
                      Command="UpdatePageTemplateOnPage"
                      Image32by32="/_layouts/15/$Resources:core,Language;/images/formatmap32x32.png?rev=23" Image32by32Left="-273" Image32by32Top="-273"
                      LabelText="Update Page Template"
                      TemplateAlias="o1"
                      Sequence="50" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="UpdatePageTemplateOnPage"
          CommandAction="javascript:LaunchUpdateTemplatePage();" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
  <CustomAction Id="UpdatePageTemplateInList" Location="CommandUI.Ribbon" RegistrationType="List" RegistrationId="13819" Rights="EditListItems,AddAndCustomizePages">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
          <Button Id="Ribbon.Documents.Manage.Controls.UpdatePageTemplateInList"
                      Command="ShowAlert"
                      Image32by32="/_layouts/15/$Resources:core,Language;/images/formatmap32x32.png?rev=23" Image32by32Left="-273" Image32by32Top="-273"
                      LabelText="Update Selected Pages Template"
                      TemplateAlias="o1"
                      Sequence="50" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="ShowAlert"
          CommandAction="javascript:LaunchUpdateTemplatePageList();"
          EnabledScript="javascript:
                          function isEnabled()
                          {
                          var selectedPages = SP.ListOperation.Selection.getSelectedItems();
                          return (selectedPages.length &gt; 0);
                          }
                          isEnabled();" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
